<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">
        <title>地址管理</title>
        <link href="__MZUI__/css/admin.css" rel="stylesheet" type="text/css">
        <link href="__MZUI__/css/amazeui.css" rel="stylesheet" type="text/css">
        <link href="__CSS__/user/personal.css" rel="stylesheet" type="text/css">
        <link href="__CSS__/user/addstyle.css" rel="stylesheet" type="text/css">
        <script src="__MZUI__/js/jquery.min.js" type="text/javascript"></script>
        <link href="__CSS__/common.css" rel="stylesheet" type="text/css">
        <script src="__MZUI__/js/amazeui.js"></script>
        <script type="text/javascript" src="__JQ__"></script>
        <script type="text/javascript" src="__JS__/public.lib.js"></script>
        <script type="text/javascript" src="__YZ__"></script>
        <script type="text/javascript" src="__LY__"></script>
        <script type="text/javascript" src="__JS__/jquery.form.js"></script>
        <script type="text/javascript" src="__JS__/jquery.submit.js"></script>
    </head>
    <body>
    <include file="Include/top" />
        <include file="Include/header" />
        <div class="center">
            <div class="col-main">
                <div class="main-wrap">
                    <div class="user-address">
                        <!--标题 -->
                        <div class="am-cf am-padding">
                            <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">地址管理</strong> / <small>Address&nbsp;list</small></div>
                        </div>
                        <hr/>
                        <ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">
                            <foreach item="v" name="address">
                            <if condition="$v['is_default'] eq 1">
                            <li class="user-addresslist defaultAddr">
                                <span class="new-option-r" rid="{$v['address_id']}"><i class="am-icon-check-circle"></i>默认地址</span>
                            <else />
                            <li class="user-addresslist">
                                <span class="new-option-r" rid="{$v['address_id']}"><i class="am-icon-check-circle"></i>设为默认</span>
                            </if>
                                <p class="new-tit new-p-re">
                                    <span class="new-txt">{$v['true_name']}</span>
                                    <span class="new-txt-rd2">{$v['mob_phone']}</span>
                                </p>
                                <div class="new-mu_l2a new-p-re">
                                    <p class="new-mu_l2cw">
                                        <span class="title">地址：</span>
                                        <span class="province">{$v['area_info']}</span>
                                        <span class="street">{$v['address']}</span>
                                    </p>
                                </div>
                                <div class="new-addr-btn">
                                    <a href="#"><i class="am-icon-edit"></i>编辑</a>
                                    <span class="new-addr-bar">|</span>
                                    <a href="javascript:void(0);" onclick="delClick({$v['address_id']});"><i class="am-icon-trash"></i>删除</a>
                                </div>
                            </li>
                            </foreach>
                        </ul>
                        <div class="clear"></div>
                        <a class="new-abtn-type" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
                        <!--例子-->
                        <div class="am-modal am-modal-no-btn" id="doc-modal-1">
                            <div class="add-dress">
                                <!--标题 -->
                                <div class="am-cf am-padding">
                                    <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add&nbsp;address</small></div>
                                </div>
                                <hr/>
                                <div class="am-u-md-12 am-u-lg-8" style="margin-top: 20px;">
                                    <form class="am-form am-form-horizontal" action="" name="myform" id="myform" method="post" onsubmit="return addcity(this)" >

                                        <div class="am-form-group">
                                            <label for="user-name" class="am-form-label">收货人：</label>
                                            <div class="am-form-content">
                                                <input type="text" id="user-name" name="true_name" datatype="*" placeholder="收货人">
                                                <div class="label Validform_checktip"></div>
                                            </div>
                                        </div>

                                        <div class="am-form-group">
                                            <label for="user-phone" class="am-form-label">手机号：</label>
                                            <div class="am-form-content">
                                                <input id="user-phone" placeholder="手机号必填" datatype="m" name="mob_phone" type="text">
                                                <div class="label Validform_checktip"></div>
                                            </div>
                                        </div>
                                        <div class="am-form-group">
                                            <label for="user-address" class="am-form-label">所在地：</label>
                                            <div class="am-form-content address">
                                            <div id="region">
                                                <input type="hidden" value="" name="city_id" id="city_id">
                                                <input type="hidden" name="area_id" id="area_id" value="" class="area_ids" />
                                                <input type="hidden" name="area_info" id="area_info" value="" class="area_names" />
                                                <select></select>
                                                <div class="label Validform_checktip"></div>
                                            </div>
                                            </div>
                                        </div>

                                        <div class="am-form-group">
                                            <label for="user-intro" class="am-form-label">详细地址：</label>
                                            <div class="am-form-content">
                                                <textarea class="" rows="3" id="user-intro" name="address" datatype="*" placeholder="输入详细地址"></textarea>
                                                <small>100字以内写出你的详细地址...</small>
                                                <div class="label Validform_checktip"></div>
                                            </div>
                                        </div>

                                        <div class="am-form-group">
                                            <div class="am-u-sm-9 am-u-sm-push-3">
                                                <input type="submit" class="am-btn am-btn-danger" id="btn_submit" name="btn_submit" value="保存">
                                                <a href="javascript: void(0)" class="am-close am-btn am-btn-danger" data-am-modal-close>取消</a>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                    <script type="text/javascript">
                        $(document).ready(function () {
                            $(".new-option-r").click(function () {
                                var address_id = $(this).attr('rid');
                                var data = {address_id:address_id};
                                p = Aajax("{:U('/Address/defaultSite')}", data);
                                if(p.status){
                                    $(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
                                }else{
                                    layer.msg(p.msg);
                                }
                            });
                            var $ww = $(window).width();
                            if ($ww > 640) {
                                $("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
                            }

                        })
                        function delClick(address_id){
                            var data = {address_id:address_id};
                            p = Aajax("{:U('/Address/delAddress')}", data);
                            if(p.status){
                                layer.msg(p.msg);
                                window.location.reload();
                            }else{
                                layer.msg(p.msg);
                            }
                        }
                    </script>
                    <div class="clear"></div>
                </div>
            </div>
           <include file="Include/navigation" />
        </div>
        <include file="Include/footer" />
    </body>
</html>
<!--F 省市区三级联动-->
<script type="text/javascript" src="__JS__/region.js"></script>
<script src="/Public/js/common_select.js"></script>
<script type="text/javascript">
    regionInit("region");
    $("#myform").Validform({
        tiptype: 3,
        showAllError:true,
    });
    $('#myform').layer({});
    function addcity(){
        if ($("#region > select").eq(1).val()>0) $('#city_id').val($("#region > select").eq(1).val());
        if(!submitaddajax()){
            return false;
        }
    }
</script>
<!--E 省市区三级联动-->